<script setup>
import {ref} from 'vue';
import {showMessageError} from "@/utils/dialog.js";
import {getSystemInfo} from "@/store/cache.js";

const title = ref("")
// 版本信息
const version = ref(import.meta.env.VITE_VUE_APP_VERSION)
// git 地址
const gitURL = ref(import.meta.env.VITE_VUE_APP_GIT_URL)
// 版权信息
const copyRight = ref('')
const props = defineProps({
  textColor: {
    type: String,
    default: '#ffffff'
  }
})

// 获取系统配置
getSystemInfo().then(res => {
  title.value = res.data.title ?? import.meta.env.VITE_VUE_APP_TITLE
  copyRight.value = res.data.copyright.length > 1 ? res.data.copyright : 'Easy-AI-Chat © 2023 - '+new Date().getFullYear()+' All rights reserved.'
}).catch(e => {
  showMessageError('获取系统配置失败：'+e.message)
})

</script>

<template>
  <div class="foot-container">
    <div class="footer">
      <div>
        <span>{{copyRight}}</span>
      </div>
      <a :href="gitURL" target="_blank">
        {{ title }} - {{ version }}
      </a>
    </div>
  </div>
</template>

<style scoped lang="stylus">
.foot-container {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  display flex;
  justify-content center
  background: var(--theme-bg);
  margin-top -4px

  .footer {
    max-width 400px;
    text-align center;
    font-size 14px;
    padding 20px;
    width 100%

    a {
      color:var(--text-color)
      &:hover {
        text-decoration underline
      }
    }
    span{
      color:var(--text-color)
    }
  }
}
</style>